﻿
var urlstr = '';
if (window.location.host.search("localhost") != -1) {
    urlstr = '/IFS/ifs.ashx';
}
else {
    urlstr = 'http://ifunsoccer.com/ifs/ifs.ashx';
}


function checkemail(v_val) {
    var str = v_val;
    var filter = /^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i
    if (filter.test(str))
        testresults = true
    else {
        testresults = false
    }
    return (testresults)
}



function sendemailletter(type,email) {

    if (email == '') {
        alert('กรุณาใส่อีเมล์แอ็ดเดรส'); 
        return false;
    }
    else if (email != '') {
        if (checkemail(email) == false) {
            alert('กรุณาใส่อีเมล์แอ็ดเดรส ที่ถูกต้อง'); 
            return false;
        }
    }


    //=================
    if (1 == 1) {
        $.ajax({
            url: 'SSEHandler.ashx',
            type: 'GET',
            dataType: 'json',
            data: { method: 'savecontactus',
                topic: '[receive new letter]',
                firstname: '-',
                lastname: '-',
                email: email,
                tell: '-',
                msg: '-',
                type: type
            },
            success: function (data) {
                if (data.result == 'true') {
			alert("สมัครเรียบร้อยแล้ว");
		} else {
		alert(data.msg);
		}
            }
        });

    }

} 